package com.drinks.yiniang.adapter.viewpager;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.view.ViewGroup;

import com.hansen.library.ui.fragment.BaseLazyFragment;
import com.hansen.library.pickerview.bean.CodeValueBean;
import com.hansen.library.utils.CommonUtils;

import java.util.List;

/**
 * 我的订单tab adapter
 * @author han
 * @date 2019/9/4
 */
public class CodeTabFragmentAdapter extends FragmentStatePagerAdapter {

    private List<BaseLazyFragment> fragments;
    private List<CodeValueBean> mTabs;

    public CodeTabFragmentAdapter(FragmentManager fm, List<BaseLazyFragment> fragments, List<CodeValueBean> mTabs) {
        super(fm);
        this.fragments = fragments;
        this.mTabs = mTabs;
    }

    @Override
    public Fragment getItem(int position) {
        return fragments != null ? fragments.get(position) : null;
    }

    @Override
    public int getCount() {
        return CommonUtils.getListSize(fragments);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        super.destroyItem(container, position, object);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mTabs != null ? mTabs.get(position).getValue() : "";
    }
}
